/**
 *
 * 用户登录接口
 *
 */
const rootPath = '../../../';
const router = require('express').Router();
const baseTool = require(rootPath + 'common/base-tool');
const baseRole = require(rootPath + 'common/base-role');
const tips = require(rootPath + 'common/tips');
const log = require(rootPath + 'common/log');
const CURD = require(rootPath + 'compontents/DB/CURDClass')
const RSA = require(rootPath + 'common/RSAClass');
const md5 = require('md5-node');
const expressWs = require('express-ws');
expressWs(router);

router.post('/loginOut', async (req, res, next) => {
    log.api('user login out');

    /**
     * =======================
     *      登出
     * =======================
     */
    const xhtk = req.cookies.xhtk;
    const uid = req.cookies.uid;
    const room = req.body.room;

    res.clearCookie('xhtk')
    res.clearCookie('uid')

    baseRole.offOnline(room, uid, ename).then(()=>{
        res.json({
            code: tips.successCode,
            msg: tips.success
        });
    })
})
module.exports = router;